Skip to content

Conversation

WaVEV
Copy link
Collaborator

@WaVEV WaVEV commented Sep 17, 2024

fixes #121

# expression.
"let": {
f"{parent_template}{i}": parent_field
f"{parent_template}{i}": {"$toString": parent_field}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that doing toString unconditionally is best. I think Django's SQL joining logic examines the the target field and only casts as necessary. Did you investigate this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not much to be honest, I just asume that the field can be casted as string, but I will do a research of this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that I have to refactor Cast in order to support it. There is a tiny difference in our flow and postgres (or other sql) flow. But It is doable.

Copy link
Collaborator Author

@WaVEV WaVEV Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, We can't cast to objectId but we can meet in the middle casting to string if the types are different.

@WaVEV WaVEV force-pushed the add-support-for-GenericForeignKey-and-GenericRelation branch from 678a08f to 7f53f46 Compare September 23, 2024 15:11
with:
repository: 'mongodb-forks/django'
ref: 'mongodb-5.0.x'
repository: 'wavev/django'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test failure is because of some new test on the Django fork. I merged in the changes from your branch, so you can use mongodb-5.0.x again.

Incidentally, can you structure this as two commits:

  1. "add generic_relations tests to CI"
  2. the fix (which removes the expected test failures added in commit 1 so it's more clear what's fixed)

Copy link
Collaborator Author

@WaVEV WaVEV Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved.

@WaVEV WaVEV force-pushed the add-support-for-GenericForeignKey-and-GenericRelation branch from 1ca96d9 to a9e908d Compare September 24, 2024 01:22
@timgraham timgraham force-pushed the add-support-for-GenericForeignKey-and-GenericRelation branch from fd4302d to 8b98b58 Compare September 24, 2024 15:00
@timgraham timgraham changed the title Add support for generic foreign key and generic relation fix GenericRelation object_id / target id join type mismatch Sep 24, 2024
@timgraham timgraham merged commit 8b98b58 into mongodb:main Sep 24, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add support for GenericForeignKey and GenericRelation

2 participants